package com.boyadegroot.divelog.models;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;

public class DiveTrip implements Parcelable, Comparable<DiveTrip> {

    private static final String TAG = DiveTrip.class.getName();

    private long mId;
    private String mDestination;

    public DiveTrip() {}

    public DiveTrip(long id, String destination) {
        this.setId(id);
        this.setDestination(destination);
    }

    public long getId() {
        return mId;
    }

    public void setId(long id) {
        this.mId = id;
    }

    public String getDestination() {
        return mDestination;
    }

    public void setDestination(String destination) {
        this.mDestination = destination;
    }

    @Override
    public int compareTo(@NonNull DiveTrip another) {
        return this.mDestination.compareTo(another.mDestination);
    }

    @Override
    public String toString() {
        return getDestination();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(mId);
        dest.writeString(mDestination);
    }

    public static final Parcelable.Creator<DiveTrip> CREATOR = new Parcelable.Creator<DiveTrip>() {

        public DiveTrip createFromParcel(Parcel in) {
            return new DiveTrip(in);
        }

        public DiveTrip[] newArray(int size) {
            return new DiveTrip[size];
        }
    };

    private DiveTrip(Parcel in) {
        mId = in.readLong();
        mDestination = in.readString();
    }
}
